Unit FaturaResimEkleme;

Interface

Uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, StdCtrls, Buttons, DBCtrls, ExtCtrls, siComp,
  siLngLnk;

Type
  TFaturaResimEklemeF = Class(TForm)
    Resim2k: TDBImage;
    bekle: TBitBtn;
    Fatura_ResimQ: TADOQuery;
    Fatura_ResimQS: TDataSource;
    bsil: TBitBtn;
    bkapat: TBitBtn;
    OpenDialog1: TOpenDialog;
    DBNavigator1: TDBNavigator;
    Procedure FormClose(Sender: TObject; Var Action: TCloseAction);
    Procedure FormShow(Sender: TObject);
    Procedure bekleClick(Sender: TObject);
    Procedure bsilClick(Sender: TObject);
    Procedure bkapatClick(Sender: TObject);
  Private
    { Private declarations }
    FaturaID: integer;
    tipi: char;
  Public
    { Public declarations }
  End;

Var
  FaturaResimEklemeF: TFaturaResimEklemeF;

Implementation

Uses data, ana1;

{$R *.dfm}

Procedure TFaturaResimEklemeF.FormClose(Sender: TObject;
  Var Action: TCloseAction);
Begin
  Action := CaFree;
  FaturaResimEklemeF := Nil;
End;

Procedure TFaturaResimEklemeF.FormShow(Sender: TObject);
Begin
  YerAyarla(Self, True);
  FaturaID := dm.islemid;
  tipi := dm.nerden;

  Fatura_ResimQ.close;
  Fatura_ResimQ.SQL.text := 'select * from Fatura_Resim where faturaid=:faturaid and tipi=' + #39 + tipi + #39;
  Fatura_ResimQ.Parameters.ParamByName('faturaid').value := FaturaID;
  Fatura_ResimQ.open;
End;

Procedure TFaturaResimEklemeF.bekleClick(Sender: TObject);
Begin
  If OpenDialog1.execute Then
  Begin
    Fatura_ResimQ.Append;
    Fatura_ResimQ.FieldByName('faturaid').Value := FaturaID;
    Fatura_ResimQ.FieldByName('tipi').Value := tipi;

    Resim2k.Picture.LoadFromFile(OpenDialog1.FileName);
    Resim2k.CopyToClipboard;
    Resim2k.PasteFromClipboard;
    Fatura_ResimQ.Post;

    Resim2k.Visible := True;
  End;
End;

Procedure TFaturaResimEklemeF.bsilClick(Sender: TObject);
Begin
  Fatura_ResimQ.Edit;
  Fatura_ResimQ.fieldbyname('resim').value := null;
  Fatura_ResimQ.Post;

  Resim2k.Visible := False;
End;

Procedure TFaturaResimEklemeF.bkapatClick(Sender: TObject);
Begin
  Close;
End;

End.
